package org.goodsence.therevolt.controller;

import org.goodsence.api.ModernArrangedMarriageApi;
import org.goodsence.frammework.common.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zty
 * @apiNote
 * @project_name the-revolt
 * @user tain
 * @create_at 2023/6/14 19:16
 * @create_vio IntelliJ IDEA
 */
@RestController
@RequestMapping("/test")
public class TestController {

    private final ModernArrangedMarriageApi modernArrangedMarriageApi;

    private final StringRedisTemplate stringRedisTemplate;


    @Autowired
    public TestController(ModernArrangedMarriageApi modernArrangedMarriageApi, StringRedisTemplate stringRedisTemplate) {
        this.modernArrangedMarriageApi = modernArrangedMarriageApi;
        this.stringRedisTemplate = stringRedisTemplate;
    }

    @GetMapping("/api")
    public ResponseEntity<String> test(){
        String msg = modernArrangedMarriageApi.test();
        return ResultUtils.ok(msg);
    }

    @GetMapping("/redis/get/{key}")
    public ResponseEntity<String> redisGet(@PathVariable String key){
        String value = stringRedisTemplate.opsForValue().get(key);
        return ResultUtils.ok(value);
    }
}
